package ${packageName}.view;

import com.jspx.boot.environment.Environment;
import com.jspx.txweb.annotation.HttpMethod;
import com.jspx.txweb.annotation.Safety;
import com.jspx.txweb.annotation.TurnPage;
import com.jspx.utils.StringUtil;
import com.jspx.utils.ArrayUtil;
import java.text.ParseException;
import java.util.List;
import ${packageName}.table.${className};

/**
 * Created by jspx.net maker
 * User: chenYuan
 * DateTime: ${date.string('yyyy-MM-dd HH:mm')}
 * ${packageName}.view.${className}
 * 提供页面显示列表
 */
@HttpMethod(caption = "${title}列表")
public class ${className}ListView extends ${className}View
{
    private String term = StringUtil.empty;
    private String sort = "createDate:D";//"sortType:D;sortDate:D;createDate:D";

    private long uid = 0;
    private int count = 0;
    private String[] field = ArrayUtil.emptyString;
    private String[] find = ArrayUtil.emptyString;
    private int currentPage = 1;

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage)
    {
        this.currentPage = currentPage;
    }

    public int getCount() {
        if (count <= 0) {
            count = config.getInt(Environment.rowCount,12);
        }
        return count;
    }

    @Safety
    public void setCount(int count) {
        this.count = count;
    }

    public String getTerm() {
        return term;
    }

    @Safety
    public void setTerm(String term) {
        this.term = term;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public String[] getField() {
        return field;
    }
    @Safety
    public void setField(String[] field) {
        this.field = field;
    }

    public String[] getFind() {
        return find;
    }
    @Safety
    public void setFind(String[] find) {
        this.find = find;
    }

/*
     老式翻页方式,ajax方式不需要
    private String turnPage = StringUtil.empty;
    @Safety(request = false)
    @TurnPage(params = "find;uid;sort")
    public void setTurnPage(String turnPage) {
        this.turnPage = turnPage;
    }

    public String getTurnPage() {
        return turnPage;
    }
*/
    /**
     * @return 列表
     * @throws ParseException 异常
     */
    public List<${className}> getList() throws Exception {
        return ${className.firstLowerCase()}DAO.getList(field,find, term, uid, sort, getCurrentPage(), getCount());
    }

    /**
     * @return 记录数量
     * @throws ParseException 异常
     */
    public int getTotalCount() throws Exception {
        return ${className.firstLowerCase()}DAO.getCount(field,find, term, uid);
    }
}